package com.ruoyi.tiktok.mapper;

import com.ruoyi.tiktok.domain.Video;
import org.apache.ibatis.annotations.*;

@Mapper
public interface VideoMapper {
    @Insert("INSERT INTO Videos(videoId, uploadDate, updateUserId, beUsed, coverImg, fileSize, s3Url) " +
            "VALUES(#{videoId}, #{uploadDate}, #{updateUserId}, #{beUsed}, #{coverImg}, #{fileSize}, #{s3Url})")
    void insertVideo(Video video);

    @Update("UPDATE Videos SET uploadDate=#{uploadDate}, updateUserId=#{updateUserId}, beUsed=#{beUsed}, coverImg=#{coverImg}, " +
            "fileSize=#{fileSize}, s3Url=#{s3Url} WHERE videoId=#{videoId}")
    void updateVideo(Video video);

    @Delete("DELETE FROM Videos WHERE videoId=#{videoId}")
    void deleteVideo(String videoId);

    @Select("SELECT * FROM Videos WHERE videoId=#{videoId}")
    Video getVideoById(String videoId);
}
